%%
%% theme.tex
%% Made by nicuveo <antoine.jp.leblanc@gmail.com>
%%


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Base theme

\mode<presentation>{}
\usecolortheme{whale}
%\usepackage{fontspec}
\usepackage{etoolbox}
\setsansfont[Ligatures=TeX, % recommended
             UprightFont={*-Regular},
             ItalicFont={*-Regular},
             BoldFont={*-Bold},
             BoldItalicFont={*-Bold}]
             {Yanone Kaffeesatz}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Colors

% define

\definecolor{google-r}{RGB}{234,  67,  53}
\definecolor{google-g}{RGB}{ 52, 168,  83}
\definecolor{google-b}{RGB}{ 66, 133, 244}
\definecolor{google-y}{RGB}{251, 188,   5}

\definecolor{my-color-1}{RGB}{ 66, 133, 244} % primary
\definecolor{my-color-2}{RGB}{234,  67,  53} % lighter
\definecolor{my-color-3}{RGB}{  0,   0,   0} % unknown
\definecolor{my-color-4}{RGB}{  0,   0,   0} % darker

\definecolor{tab-1}{rgb}{0.04,0.34,0.58}
\definecolor{tab-2}{rgb}{0.36,0.56,0.72}
\definecolor{tab-3}{rgb}{0.68,0.78,0.86}


% set

\setbeamercolor{structure}{fg=my-color-1}
\setbeamercolor{alerted text}{fg=my-color-2}

\setbeamercolor{palette primary}   {fg=white, bg=my-color-1}
\setbeamercolor{palette secondary} {fg=black, bg=my-color-2}
\setbeamercolor{palette tertiary}  {fg=white, bg=my-color-3}
\setbeamercolor{palette quaternary}{fg=white, bg=my-color-4}

\setbeamercolor{page number in head/foot} {fg=black, bg=white}
\setbeamercolor{icon in head/foot} {fg=black, bg=white}

\setbeamercolor*{separation line}{}
\setbeamercolor*{fine separation line}{}



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Templates

\newtoggle{showpagenumber}

\setbeamertemplate{headline}[default]
\defbeamertemplate{footline}{mine}[2]
{
  \leavevmode%
  \hbox
  {%
    \hskip .020\paperwidth

    \begin{beamercolorbox}[wd=.160\paperwidth,ht=3ex,dp=3ex,center]{icon in head/foot}
      \pgfimage[mask=#2,interpolate=true,height=14pt]{#1}
    \end{beamercolorbox}%

    \hskip .720\paperwidth

    \begin{beamercolorbox}[wd=.100\paperwidth,ht=3ex,dp=3ex,center]{page number in head/foot}
      \usebeamerfont{page number in head/foot}
      \iftoggle{showpagenumber}{
        \insertframenumber{} / \inserttotalframenumber{}
      }{}
      \end{beamercolorbox}%
  }%
  \vskip0pt%
}


\newcounter{SectionColorCounter}
\AtBeginSection[]
{
  \ifnum\value{SectionColorCounter}=0
    \setbeamercolor{palette primary}{fg=white, bg=google-g}
    \setbeamercolor{frametitle}{fg=white, bg=google-g}
    \setbeamercolor{structure}{fg=google-g}
    \setbeamercolor{alerted text}{fg=google-g}
  \fi
  \ifnum\value{SectionColorCounter}=1
    \setbeamercolor{palette primary}{fg=white, bg=google-b}
    \setbeamercolor{frametitle}{fg=white, bg=google-b}
    \setbeamercolor{structure}{fg=google-b}
    \setbeamercolor{alerted text}{fg=google-b}
  \fi
  \ifnum\value{SectionColorCounter}=2
    \setbeamercolor{palette primary}{fg=white, bg=google-r}
    \setbeamercolor{frametitle}{fg=white, bg=google-r}
    \setbeamercolor{structure}{fg=google-r}
    \setbeamercolor{alerted text}{fg=google-r}
  \fi
  \ifnum\value{SectionColorCounter}=3
    \setbeamercolor{palette primary}{fg=white, bg=google-y}
    \setbeamercolor{frametitle}{fg=white, bg=google-y}
    \setbeamercolor{structure}{fg=google-y}
    \setbeamercolor{alerted text}{fg=google-y}
  \fi

  \stepcounter{SectionColorCounter}
  \ifnum\value{SectionColorCounter}=4
    \setcounter{SectionColorCounter}{0}
  \fi
}

% \AtBeginSection[]
% {
%    \begin{frame}
%        \frametitle{Outline}
%        \tableofcontents[currentsection,hideothersubsections]
%    \end{frame}
% }

\newcommand{\setfooterlogo}[2]
{
  \setbeamertemplate{footline}[mine]{#1}{#2}
}

%\pgfdeclaremask{masklogo}{img/logo}
\newcommand\defaultlogo{\setfooterlogo{img/google}{}}
\defaultlogo

\setbeamersize{text margin left=10pt,text margin right=10pt}



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Code environnement

\definecolor{hsk-comment}   {gray}{0.5}
\colorlet{hsk-built-ins}    {google-g}
\definecolor{hsk-types}        {rgb}{0, 0.53, 0.69}
\definecolor{hsk-typevar}      {rgb}{0.82, 0.41, 0.12}
% \definecolor{hsk-typevar}      {rgb}{0.65, 0.32, 0.18}
% \definecolor{hsk-typevar}      {rgb}{0.0, 0.0, 0.8}
\definecolor{hsk-constructors} {rgb}{0.85, 0.65, 0.13}
\definecolor{hsk-operators}    {rgb}{0.84, 0.0, 0.53}
\definecolor{hsk-keywords}     {rgb}{0.0, 0.37, 0.69}
\definecolor{hsk-strings}      {rgb}{0.37, 0.53, 0.0}

\lstdefinelanguage{ColorHaskell} {
        basicstyle=\ttfamily\footnotesize,
        sensitive=true,
        morecomment=[l][\color{hsk-comment}\ttfamily\footnotesize]{--},
        morecomment=[s][\color{hsk-comment}\ttfamily\footnotesize]{\{-}{-\}},
        morestring=[b]",
        stringstyle=\color{hsk-strings},
        showstringspaces=false,
        numberstyle=none,
        showspaces=false,
        breaklines=true,
        showtabs=false,
        emph=
        {[1]
                abs,acos,acosh,all,and,any,appendFile,approxRational,asTypeOf,asin,
                asinh,atan,atan2,atanh,basicIORun,break,catch,ceiling,chr,compare,concat,concatMap,
                const,cos,cosh,curry,cycle,decodeFloat,denominator,digitToInt,divMod,drop,
                dropWhile,either,encodeFloat,enumFrom,enumFromThen,enumFromThenTo,enumFromTo,
                error,even,exp,exponent,fail,filter,flip,floatDigits,floatRadix,floatRange,floor,
                fmap,bind,ap,foldl,foldl1,foldr,foldr1,fromDouble,fromEnum,fromInt,fromInteger,fromIntegral,
                fromRational,fst,gcd,getChar,getContents,getLine,head,id,inRange,index,init,intToDigit,
                interact,ioError,isAlpha,isAlphaNum,isAscii,isControl,isDenormalized,isDigit,isHexDigit,
                isIEEE,isInfinite,isLower,isNaN,isNegativeZero,isOctDigit,isPrint,isSpace,isUpper,iterate,
                last,lcm,lex,lexDigits,lexLitChar,lines,log,logBase,lookup,map,mapM,mapM_,max,
                maxBound,maximum,maybe,min,minBound,minimum,negate,not,null,numerator,odd,
                or,ord,otherwise,pi,pred,primExitWith,print,product,properFraction,putChar,putStr,putStrLn,
                quotRem,range,rangeSize,read,readDec,readFile,readFloat,readHex,readIO,readInt,readList,readLitChar,
                readLn,readOct,readParen,readSigned,reads,readsPrec,realToFrac,recip,repeat,replicate,return,
                reverse,round,scaleFloat,scanl,scanl1,scanr,scanr1,sequence,sequence_,showChar,showInt,
                showList,showLitChar,showParen,showSigned,showString,shows,showsPrec,significand,signum,sin,
                sinh,snd,span,splitAt,sqrt,subtract,succ,sum,tail,take,takeWhile,tan,tanh,threadToIOResult,toEnum,
                toInt,toInteger,toLower,toRational,toUpper,truncate,uncurry,undefined,unlines,until,unwords,unzip,
                unzip3,userError,words,writeFile,zip,zip3,zipWith,zipWith3,listArray,doParse
        },
        emphstyle={[1]\color{hsk-built-ins}},
        emph=
        {[2]
                FilePath,IOError,Bool,Char,Double,Either,Float,IO,Integer,Int,Maybe,Ordering,Rational,Ratio,ReadS,ShowS,String, Word8,InPacket
        },
        emphstyle={[2]\color{hsk-types}},
        emph=
        {[3]
                case,class,data,deriving,do,else,if,import,in,infixl,infixr,instance,let,
                module,of,primitive,then,type,where
        },
        emphstyle={[3]\color{hsk-keywords}\textbf},
        emph=
        {[4]
                quot,rem,div,mod,elem,notElem,seq
        },
        emphstyle={[4]\color{hsk-operators}\textbf},
        emph=
        {[5]
                EQ,GT,Just,LT,Left,Nothing,Right,Show,Eq,Ord,Num,Enum,Bounded,Minutes
        },
        emphstyle={[5]\color{hsk-constructors}\textbf}
}

\lstdefinelanguage{ColorHaskellWithTypeVars} {
        basicstyle=\ttfamily\footnotesize,
        sensitive=true,
        morecomment=[l][\color{hsk-comment}\ttfamily\footnotesize]{--},
        morecomment=[s][\color{hsk-comment}\ttfamily\footnotesize]{\{-}{-\}},
        morestring=[b]",
        stringstyle=\color{hsk-strings},
        showstringspaces=false,
        numberstyle=none,
        showspaces=false,
        breaklines=true,
        showtabs=false,
        emph=
        {[1]
                abs,acos,acosh,all,and,any,appendFile,approxRational,asTypeOf,asin,
                asinh,atan,atan2,atanh,basicIORun,break,catch,ceiling,chr,compare,concat,concatMap,
                const,cos,cosh,curry,cycle,decodeFloat,denominator,digitToInt,divMod,drop,
                dropWhile,either,encodeFloat,enumFrom,enumFromThen,enumFromThenTo,enumFromTo,
                error,even,exp,exponent,fail,filter,flip,floatDigits,floatRadix,floatRange,floor,
                fmap,bind,ap,foldl,foldl1,foldr,foldr1,fromDouble,fromEnum,fromInt,fromInteger,fromIntegral,
                fromRational,fst,gcd,getChar,getContents,getLine,head,id,inRange,index,init,intToDigit,
                interact,ioError,isAlpha,isAlphaNum,isAscii,isControl,isDenormalized,isDigit,isHexDigit,
                isIEEE,isInfinite,isLower,isNaN,isNegativeZero,isOctDigit,isPrint,isSpace,isUpper,iterate,
                last,lcm,length,lex,lexDigits,lexLitChar,lines,log,logBase,lookup,map,mapM,mapM_,max,
                maxBound,maximum,maybe,min,minBound,minimum,negate,not,null,numerator,odd,
                or,ord,otherwise,pi,pred,primExitWith,print,product,properFraction,putChar,putStr,putStrLn,
                quotRem,range,rangeSize,read,readDec,readFile,readFloat,readHex,readIO,readInt,readList,readLitChar,
                readLn,readOct,readParen,readSigned,reads,readsPrec,realToFrac,recip,repeat,replicate,return,
                reverse,round,scaleFloat,scanl,scanl1,scanr,scanr1,sequence,sequence_,show,showChar,showInt,
                showList,showLitChar,showParen,showSigned,showString,shows,showsPrec,significand,signum,sin,
                sinh,snd,span,splitAt,sqrt,subtract,succ,sum,tail,take,takeWhile,tan,tanh,threadToIOResult,toEnum,
                toInt,toInteger,toLower,toRational,toUpper,truncate,uncurry,undefined,unlines,until,unwords,unzip,
                unzip3,userError,words,writeFile,zip,zip3,zipWith,zipWith3,listArray,doParse
        },
        emphstyle={[1]\color{hsk-built-ins}},
        emph=
        {[2]
                FilePath,IOError,Bool,Char,Double,Either,Float,IO,Integer,Int,Maybe,Ordering,Rational,Ratio,ReadS,ShowS,String, Word8,InPacket
        },
        emphstyle={[2]\color{hsk-types}},
        emph=
        {[3]
                case,class,data,deriving,do,else,if,import,in,infixl,infixr,instance,let,
                module,newtype,of,primitive,then,type,where
        },
        emphstyle={[3]\color{hsk-keywords}\textbf},
        emph=
        {[4]
                quot,rem,div,mod,elem,notElem,seq
        },
        emphstyle={[4]\color{hsk-operators}\textbf},
        emph=
        {[5]
                EQ,GT,Just,LT,Left,Nothing,Right,Show,Eq,Ord,Num,Enum,Bounded
        },
        emphstyle={[5]\color{hsk-constructors}\textbf},
        emph=
        {[6]
                a,b,c,m,t
        },
        emphstyle={[6]\color{hsk-typevar}\textbf}
}

\lstnewenvironment{code}[1][Haskell]
    {\lstset{
        language=ColorHaskellWithTypeVars,
        basicstyle=\footnotesize\ttfamily,
        flexiblecolumns=false,
        basewidth={0.5em,0.45em},
        escapeinside={(*}{*)},
        frame=trlb,
        frameround=tttt,
        literate={`\\}{{$\lambda$}}1
                 {`\\\\}{{\char`\\\char`\\}}1
                 {`->}{{$\rightarrow$}}2
                 {`<-}{{$\leftarrow$}}2
                 {`=>}{{$\Rightarrow$}}2
                 {`>>}{{>>}}2
                 {`>>=}{{>>=}}3
                 {`>=>}{{>=>}}3
                 {`|}{{$\mid$}}1
    }\csname lst@SetFirstLabel\endcsname}
    {\csname lst@SaveFirstLabel\endcsname\begin{flushright}{\color{lightgray!90}\vspace{-15mm}\footnotesize(#1)}\end{flushright}}

% C-like code
\lstnewenvironment{ccode}[1][C++]
    {\lstset{
        language=C,
        basicstyle=\footnotesize\ttfamily,
        flexiblecolumns=false,
        keywordstyle=\color{google-g},
        basewidth={0.5em,0.45em},
        escapeinside={(*}{*)},
        frame=trlb,
        frameround=tttt,
    }\csname lst@SetFirstLabel\endcsname}
    {\csname lst@SaveFirstLabel\endcsname\begin{flushright}{\color{lightgray!90}\vspace{-15mm}\footnotesize(#1)}\end{flushright}}

% Python code
\lstnewenvironment{pycode}[1][Python]
    {\lstset{
        language=Python,
        basicstyle=\footnotesize\ttfamily,
        flexiblecolumns=false,
        keywordstyle=\color{google-g},
        basewidth={0.5em,0.45em},
        escapeinside={(*}{*)},
        frame=trlb,
        frameround=tttt,
    }\csname lst@SetFirstLabel\endcsname}
    {\csname lst@SaveFirstLabel\endcsname\begin{flushright}{\color{lightgray!90}\vspace{-15mm}\footnotesize(#1)}\end{flushright}}

\def\inlinecode{\lstinline[language=ColorHaskell,
      basicstyle=\footnotesize\ttfamily,
      flexiblecolumns=false,
      basewidth={0.5em,0.45em},
      literate={`\\}{{$\lambda$}}1
               {`\\\\}{{\char`\\\char`\\}}1
               {`->}{{$\rightarrow$}}2
               {`<-}{{$\leftarrow$}}2
               {`=>}{{$\Rightarrow$}}2
               {`>>}{{>>}}2
               {`>>=}{{>>=}}3
               {`>=>}{{>=>}}3
               {`|}{{$\mid$}}1]
  }

\newcommand<>{\ic}{\inlinecode}

\def\inlinecodewithtypevars{\lstinline[language=ColorHaskellWithTypeVars,
      basicstyle=\footnotesize\ttfamily,
      flexiblecolumns=false,
      basewidth={0.5em,0.45em},
      literate={`\\}{{$\lambda$}}1
               {`\\\\}{{\char`\\\char`\\}}1
               {`->}{{$\rightarrow$}}2
               {`<-}{{$\leftarrow$}}2
               {`=>}{{$\Rightarrow$}}2
               {`>>}{{>>}}2
               {`>>=}{{>>=}}3
               {`>=>}{{>=>}}3
               {`|}{{$\mid$}}1]
  }

\newcommand<>{\icwtv}{\inlinecodewithtypevars}


\newcommand<>{\type}[1]{\textcolor{hsk-types}{#1}}
\newcommand<>{\tvar}[1]{\textcolor{hsk-typevar}{#1}}
\newcommand<>{\cons}[1]{\textcolor{hsk-constructors}{#1}}
\newcommand<>{\bi}[1]{\textcolor{hsk-built-ins}{#1}}
\newcommand<>{\str}[1]{\textcolor{hsk-strings}{#1}}

\newcommand<>{\ict}[1]{\type{\ic{#1}}}
\newcommand<>{\icv}[1]{\tvar{\ic{#1}}}
\newcommand<>{\icc}[1]{\cons{\ic{#1}}}
\newcommand<>{\icbi}[1]{\bi{\ic{#1}}}



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Fonts

\setbeamerfont{frametitle}{size=\small}
\setbeamerfont{structure}{series=\bfseries}



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Settings

\setbeamertemplate{navigation symbols}{}

\bibliographystyle{apalike}

\mode<all>
